import config from "./config"
import api from './api'
import tool from './utils/tool'
import http from "./utils/request"

// 自定义语言包
import i18n from '@/locales'

// 自定义组件
import sImage from './components/s-image.vue'
import sTable from './components/s-table.vue'
import sUploadSingle from './components/s-upload-single.vue'
import sUploadDrag from './components/s-upload-drag.vue'
import scStatusIndicator from './components/scMini/scStatusIndicator.vue'

// 自定义指令
import auth from './directives/auth'
import auths from './directives/auths'
import authsAll from './directives/authsAll'
import role from './directives/role'

// 打印
import print from 'vue3-print-nb'

import * as Icons from '@ant-design/icons-vue'
// 使用 iconfont.cn
import { createFromIconfontCN } from '@ant-design/icons-vue';
const IconFont = createFromIconfontCN({
    scriptUrl: '//at.alicdn.com/t/c/font_4303413_q0goq1bb4u.js',
});

/**
 * 使用icon-font
 * <icon-font type="icon-cols" style="font-size: 18px; cursor: pointer;" />
 */
export default {
    install (app) {
        //挂载全局对象
        app.config.globalProperties.$t = i18n.global.t;
        app.config.globalProperties.$CONFIG = config;
        app.config.globalProperties.$TOOL = tool;
        app.config.globalProperties.$HTTP = http;
        app.config.globalProperties.$API = api;

        //注册全局组件
        app.component('sImage', sImage);
        app.component('sTable', sTable);
        app.component('sUploadSingle', sUploadSingle);
        app.component('sUploadDrag', sUploadDrag);
        app.component('scStatusIndicator', scStatusIndicator);

        //注册全局指令
        app.directive('print', print)
        app.directive('auth', auth)
        app.directive('auths', auths)
        app.directive('auths-all', authsAll)
        app.directive('role', role)

        //统一注册iconfont
        app.component('IconFont', IconFont)
        //统一注册antd图标
        for (const i in Icons) {
            app.component(i, Icons[i])
        }
    }
}
